from selenium.webdriver.support.wait import WebDriverWait

from common.DriverTools import DriverTools


class BasePage(object):
    def __init__(self):
        self.driver = DriverTools.get_driver()

    # 定义获取元素的公共方法
    def find_el(self, loc, timeout=10, poll=1):
        try:
            el = WebDriverWait(self.driver, timeout, poll).until(
                lambda x: x.find_element(*loc)
            )
            return el
        except Exception as e:
            print(f"未找到指定的元素{e}")

    # 定义填写信息的公共方法
    def input(self, el, info):
        el.clear()
        el.send_keys(info)
